

import java.util.Scanner;

public class Expressage{
    public static void main(String[] args) {
        //定义公司名称数组
        String[] CompanyNameSource = new String[100];

        //定义快递单号数组
        int[] NumberSource = new int[100];

        //定义取件码数组
        int[] CodeSource = new int[100];

        //定义快递单数下标
        int count = 0;

        Scanner input = new Scanner(System.in);
        System.out.println("=====欢迎使用新职课快递柜=====");
        while (true) { //while循环确保用户执行完一次操作之后还能执行
            System.out.println("请输入您的身份： 1-快递员；2-用户");
            int User = input.nextInt();
            if (User == 1) {
                System.out.println("请选择操作：1-快递录入 2-删除快递 3-修改快递 4-查看所有快递 5-退出系统");
                int function = input.nextInt();
                if (function == 1) {
                    System.out.println("请输入快递单号：");
                    int Number = input.nextInt();
                    NumberSource[count] = Number;  //存入快递单号数组
                    System.out.println("请输入公司名称");
                    String CompanyName = input.next();
                    CompanyNameSource[count] = CompanyName; //存入公司名称
                    int code = (int) Math.round(Math.random() * 10000);
                    System.out.println("快递已存入，取件码是：" + code);
                    CodeSource[count] = code; //存入快递码
                    count++;
                } else if (function == 2) {
                    System.out.println("请输入要删除的快递单号：");
                    int Number = input.nextInt();
                    for (int i = 0; i < NumberSource.length; i++) {
                        if (NumberSource[i] == Number) {
                            System.out.println("删除成功！");
                            break;
                        } else {
                            System.out.println("未找到快递！");
                            break;
                        }
                    }
                } else if (function == 3) {
                    System.out.println("请输入要修改的快递单号");
                    int Number = input.nextInt();
                    for (int i = 0; i < NumberSource.length; i++) {
                        if (NumberSource[i] == Number) {
                            System.out.println("请输入新的快递单号：");
                            int NewNumber = input.nextInt();
                            NumberSource[i] = NewNumber;
                            System.out.println("修改成功");
                            break;
                        } else {
                            System.out.println("未找到快递！");
                            break;
                        }
                    }
                } else if (function == 4) {
                    System.out.println("所有快递信息如下：");
                    for (int i = 0; i < NumberSource.length; i++) {
                        if (NumberSource[i] == 0) {
                            System.out.println("无快递信息！");
                            break;
                        } else {
                            System.out.println("快递编号：" + NumberSource[i]);
                            break;
                        }
                    }
                    for (int i = 0; i < CompanyNameSource.length; i++) {
                        if (CompanyNameSource[i] == null) {
                            System.out.println("无快递公司信息！");
                            break;
                        } else {
                            System.out.println("快递编号：" + NumberSource[i]);
                            break;
                        }
                    }
                    for (int i = 0; i < CompanyNameSource.length; i++) {
                        if (CompanyNameSource[i] == null) {
                            System.out.println("无快递公司信息！");
                            break;
                        } else {
                            System.out.println("快递公司：" + CompanyNameSource[i]);
                            break;
                        }
                    }
                } else if (function == 5) {
                    System.out.println("谢谢使用！");
                    break;
                }
            } else {// 普通用户
                System.out.println("请输入取件码：");
                int code = input.nextInt();
                for (int i = 0; i < CodeSource.length; i++) {
                    if (CodeSource[i] == code) {
                        System.out.println("取件成功！");
                        break;
                    } else if (CodeSource[i] != code) {
                        System.out.println("未找到该快递！");
                        break;
                    }
                }
            }
        }
    }
}


